class Player
  def play_turn(warrior)
	if warrior.health < 6
		if !warrior.feel(:left).enemy? && !warrior.feel(:right).enemy? && !warrior.feel(:forward).enemy? && !warrior.feel(:backward).enemy?
			warrior.rest!
		else
			warrior.walk!(:backward)
		end
	else
		# add your code here
		captive = false
		warrior.listen.each{|item|
			if item.to_s() == "Captive"
				captive = true
				direction = warrior.direction_of(item)
				if warrior.feel(direction).empty?
					warrior.walk!(direction)
				else
					warrior.rescue!(direction)
				end
				break
			end
		}
		if(!captive)
			if warrior.feel(warrior.direction_of_stairs).enemy?
				warrior.attack!(warrior.direction_of_stairs)
			else
				warrior.walk!(warrior.direction_of_stairs)
			end
		end
	end
  end
end
